package com.atguigu.gulimail.order.web;

import com.atguigu.gulimail.order.entity.OrderEntity;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.UUID;

@Controller
public class HelloController {

    @Autowired
    RabbitTemplate template;

    @ResponseBody
    @GetMapping("/createOrder")
    public String create(HttpSession session, HttpServletRequest servletRequest){
        OrderEntity orderEntity=new OrderEntity();
        orderEntity.setOrderSn(UUID.randomUUID().toString());
       template.convertAndSend("order-event-exchange", "order.create.order", orderEntity);

        return "ok";
    }


    @GetMapping("{page}.html")
    public String getPage(@PathVariable("page")String page){

        return page;
    }

    public static void main(String[] args) {
        int i=129;
        int j=129;
        System.out.println(i==j);
        HashMap<Object, Object> objectObjectHashMap = new HashMap<>();
        objectObjectHashMap.put("sd", "sd");

    }
}
